package com.happy_hao.topbiz.util;

//import jakarta.mail.internet.MimeMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MailUtil {

    //生成邮箱验证码的html页面
    public String createRegisterCodeContext(String captcha) {
        return "<!DOCTYPE html>\n" +
                "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"zh-CN\">\n" +
                "<head>\n" +
                "    <meta charset=\"UTF-8\">\n" +
                "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
                "    <title>验证码确认</title>\n" +
                "    <style>\n" +
                "        /* 基础样式 - 保持简单以提高QQ邮箱兼容性 */\n" +
                "        body { font-family: Arial, sans-serif; margin: 0; padding: 0; }\n" +
                "        .container { max-width: 600px; margin: 0 auto; padding: 20px; }\n" +
                "        .header { background-color: #165DFF; color: white; padding: 20px; border-radius: 8px 8px 0 0; }\n" +
                "        .content { background-color: #f5f7fa; padding: 20px; border-radius: 0 0 8px 8px; }\n" +
                "        .code-box { background-color: white; border: 1px solid #e5e6eb; border-radius: 8px; padding: 20px; text-align: center; }\n" +
                "        .digit { display: inline-block; width: 35px; height: 45px; background-color: #165DFF; color: white; \n" +
                "                font-size: 24px; font-weight: bold; margin: 0 5px; border-radius: 4px; line-height: 45px; }\n" +
                "        .footer { text-align: center; color: #86909C; font-size: 12px; margin-top: 20px; }\n" +
                "    </style>\n" +
                "</head>\n" +
                "<body>\n" +
                "    <div class=\"container\">\n" +
                "        <!-- 头部 -->\n" +
                "        <div class=\"header\">\n" +
                "            <h1 style=\"margin: 0 auto; width: fit-content;\">安全验证</h1>\n" +
                "        </div>\n" +
                "        \n" +
                "        <!-- 主体内容 -->\n" +
                "        <div class=\"content\">\n" +
                "            <p>尊敬的用户：</p>\n" +
                "            <p>您正在进行账户验证，请使用以下验证码完成操作：</p>\n" +
                "            \n" +
                "            <!-- 验证码区域 -->\n" +
                "            <div class=\"code-box\">\n" +
                "                <p>您的验证码</p>\n" +
                "                <div>\n" +
                "                    <span class=\"digit\">"+captcha.charAt(0)+"</span>\n" +
                "                    <span class=\"digit\">"+captcha.charAt(1)+"</span>\n" +
                "                    <span class=\"digit\">"+captcha.charAt(2)+"</span>\n" +
                "                    <span class=\"digit\">"+captcha.charAt(3)+"</span>\n" +
                "                    <span class=\"digit\">"+captcha.charAt(4)+"</span>\n" +
                "                    <span class=\"digit\">"+captcha.charAt(5)+"</span>\n" +
                "                </div>\n" +
                "                <p style=\"color: #86909C; font-size: 14px; margin-top: 10px;\">\n" +
                "                    验证码有效期：<strong>1分钟</strong>\n" +
                "                </p>\n" +
                "            </div>\n" +
                "            \n" +
                "            <!-- 提示信息 -->\n" +
                "            <p style=\"color: #4E5969; font-size: 14px; margin-top: 20px;\">\n" +
                "                如果您没有请求此验证码，请忽略此邮件。\n" +
                "            </p>\n" +
                "        </div>\n" +
                "        \n" +
                "        <!-- 底部 -->\n" +
                "        <div class=\"footer\">\n" +
                "            <p>© 可复用微服务. 保留所有权利.</p>\n" +
                "            <p>请勿回复此邮件，此邮箱不接收回复</p>\n" +
                "        </div>\n" +
                "    </div>\n" +
                "</body>\n" +
                "</html>\n" +
                "    ";
    }

    //生成的html页面
    public String createRegisterContext(String advice) {
        String context = "<!DOCTYPE html>\n" +
                "<html lang=\"zh-CN\">\n" +
                "<head>\n" +
                "    <meta charset=\"UTF-8\">\n" +
                "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
                "    <title>来自系统</title>\n" +
                "    <style>\n" +
                "        /* 重置样式 */\n" +
                "        body, table, td, p, a, li, blockquote {\n" +
                "            -webkit-text-size-adjust: 100%;\n" +
                "            -ms-text-size-adjust: 100%;\n" +
                "        }\n" +
                "        body {\n" +
                "            width: 100% !important;\n" +
                "            height: 100%;\n" +
                "            padding: 0;\n" +
                "            margin: 0;\n" +
                "            background-color: #f5f5f5;\n" +
                "        }\n" +
                "        table {\n" +
                "            border-collapse: collapse !important;\n" +
                "        }\n" +
                "        img {\n" +
                "            -ms-interpolation-mode: bicubic;\n" +
                "            border: 0;\n" +
                "            height: auto;\n" +
                "            line-height: 100%;\n" +
                "            outline: none;\n" +
                "            text-decoration: none;\n" +
                "        }\n" +
                "        p {\n" +
                "            display: block;\n" +
                "            margin: 13px 0;\n" +
                "        }\n" +
                "\n" +
                "        /* 邮件容器样式 */\n" +
                "        .email-container {\n" +
                "            max-width: 600px;\n" +
                "            margin: 0 auto;\n" +
                "            background-color: #ffffff;\n" +
                "            border-radius: 8px;\n" +
                "            overflow: hidden;\n" +
                "            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);\n" +
                "        }\n" +
                "        .email-header {\n" +
                "            background-color: #165DFF;\n" +
                "            color: #ffffff;\n" +
                "            padding: 20px;\n" +
                "            text-align: center;\n" +
                "        }\n" +
                "        .email-content {\n" +
                "            padding: 20px 30px;\n" +
                "        }\n" +
                "        .email-footer {\n" +
                "            padding: 20px;\n" +
                "            text-align: center;\n" +
                "            color: #888888;\n" +
                "            font-size: 12px;\n" +
                "        }\n" +
                "        .doctor-signature {\n" +
                "            margin-top: 20px;\n" +
                "            font-weight: bold;\n" +
                "        }\n" +
                "        .highlight {\n" +
                "            color: #165DFF;\n" +
                "        }\n" +
                "    </style>\n" +
                "</head>\n" +
                "<body>\n" +
                "    <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#f5f5f5\">\n" +
                "        <tr>\n" +
                "            <td align=\"center\" valign=\"top\">\n" +
                "                <div class=\"email-container\">\n" +
                "                    <!-- 邮件头部 -->\n" +
                "                    <div class=\"email-header\">\n" +
                "                        <h1>注册成功</h1>\n" +
                "                    </div>\n" +
                "                    \n" +
                "                    <!-- 邮件内容 -->\n" +
                "                    <div class=\"email-content\">\n" +
                "                        \n" +
                "                        \n" +
                "                        <div style=\"background-color: #f8f8f8; padding: 15px; border-left: 4px solid #165DFF; margin: 20px 0;\">\n" +
                "                            <ul>\n" +
                "                                <li>"+advice+"</li>\n" +
                "                            </ul>\n" +
                "                        </div>\n" +
                "                        \n" +
                "                        \n" +
                "                        <p class=\"doctor-signature\">\n" +
                "                        </p>\n" +
                "                    </div>\n" +
                "                    \n" +
                "                    <!-- 邮件底部 -->\n" +
                "                    <div class=\"email-footer\">\n" +
                "                        <p>此为系统自动发送邮件，请不要直接回复</p>\n" +
                "                    </div>\n" +
                "                </div>\n" +
                "            </td>\n" +
                "        </tr>\n" +
                "    </table>\n" +
                "</body>\n" +
                "</html>\n" +
                "    ";
        return context;
    }

}
